﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Data;
using DrugStorehouseMIS.DAL;
using DrugStorehouseMIS.Comm;

namespace DrugStorehouseMIS.BLL
{
    public class SystemFunction
    {
        #region 字段 属性

        private int mSystemFunctionID;

        public int SystemFunctionID
        {
            get { return mSystemFunctionID; }
            set { mSystemFunctionID = value; }
        }

        private int mSystemFunctionParentID;

        public int SystemFunctionParentID
        {
            get { return mSystemFunctionParentID; }
            set { mSystemFunctionParentID = value; }
        }

        private int mSystemFunctionChildID;

        public int SystemFunctionChildID
        {
            get { return mSystemFunctionChildID; }
            set { mSystemFunctionChildID = value; }
        }

        private int mSystemFunctionMenuType;

        public int SystemFunctionMenuType
        {
            get { return mSystemFunctionMenuType; }
            set { mSystemFunctionMenuType = value; }
        }

        private string mSystemFunctionDesc;

        public string SystemFunctionDesc
        {
            get { return mSystemFunctionDesc; }
            set { mSystemFunctionDesc = value; }
        }

        private int mFlagMenuFunction;

        public int FlagMenuFunction
        {
            get { return mFlagMenuFunction; }
            set { mFlagMenuFunction = value; }
        }

        private int mFlagDisable;

        public int FlagDisable
        {
            get { return mFlagDisable; }
            set { mFlagDisable = value; }
        }

        #endregion

        private DrugStorehouseMIS.DAL.Interface.ISystemFunction functionDAL;
        public SystemFunction()
        {
            functionDAL = Adapter.GetSystemFunction();
        }

        public IList GetSystemFunctionListAll()
        {
            IList list = new ArrayList();
            SystemFunction function = null;
            IDataReader dr = functionDAL.GetSystemFunctionListAll();
            while (dr!=null&& dr.Read())
            {
                function = new SystemFunction();
                function.SystemFunctionID = ConvertDataType.CheckFiledInt(dr["system_function_id"]);
                function.SystemFunctionParentID = ConvertDataType.CheckFiledInt(dr["system_function_parent_id"]);
                function.SystemFunctionChildID = ConvertDataType.CheckFiledInt(dr["system_function_child_id"]);
                function.SystemFunctionMenuType = ConvertDataType.CheckFiledInt(dr["system_function_menu_type"]);
                function.SystemFunctionDesc = ConvertDataType.CheckFiledString(dr["system_function_desc"]);
                function.FlagMenuFunction = ConvertDataType.CheckFiledInt(dr["flag_menu_function"]);
                function.FlagDisable = ConvertDataType.CheckFiledInt(dr["flag_disable"]);
                list.Add(function);
            }
            dr.Close();
            return list;
        }

        public IList GetSystemFunctionByParentID(int SystemFunctionParentID)
        {
            IList list = new ArrayList();
            SystemFunction function = null;
            IDataReader dr = functionDAL.GetSystemFunctionByParentId(SystemFunctionParentID);
            while (dr != null && dr.Read())
            {
                function = new SystemFunction();
                function.SystemFunctionID = ConvertDataType.CheckFiledInt(dr["system_function_id"]);
                function.SystemFunctionParentID = ConvertDataType.CheckFiledInt(dr["system_function_parent_id"]);
                function.SystemFunctionChildID = ConvertDataType.CheckFiledInt(dr["system_function_child_id"]);
                function.SystemFunctionMenuType = ConvertDataType.CheckFiledInt(dr["system_function_menu_type"]);
                function.SystemFunctionDesc = ConvertDataType.CheckFiledString(dr["system_function_desc"]);
                function.FlagMenuFunction = ConvertDataType.CheckFiledInt(dr["flag_menu_function"]);
                function.FlagDisable = ConvertDataType.CheckFiledInt(dr["flag_disable"]);
                list.Add(function);
            }
            dr.Close();
            return list;
        }

        public IList GetSytemFunctionByFunctionID(int SystemFunctionID)
        {
            IList list = new ArrayList();
            SystemFunction function = null;
            IDataReader dr = functionDAL.GetSystemFunctionByFunctionId(SystemFunctionID);
            while (dr.Read())
            {
                function = new SystemFunction();
                function.SystemFunctionID = ConvertDataType.CheckFiledInt(dr["system_function_id"]);
                function.SystemFunctionParentID = ConvertDataType.CheckFiledInt(dr["system_function_parent_id"]);
                function.SystemFunctionChildID = ConvertDataType.CheckFiledInt(dr["system_function_child_id"]);
                function.SystemFunctionMenuType = ConvertDataType.CheckFiledInt(dr["system_function_menu_type"]);
                function.SystemFunctionDesc = ConvertDataType.CheckFiledString(dr["system_function_desc"]);
                function.FlagMenuFunction = ConvertDataType.CheckFiledInt(dr["flag_menu_function"]);
                function.FlagDisable = ConvertDataType.CheckFiledInt(dr["flag_disable"]);
                list.Add(function);
            }
            dr.Close();
            return list;
        }
        
    }
}
